package com.itheima.health.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.health.dao.CheckGroupDao;
import com.itheima.health.entity.PageResult;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.service.CheckGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author lcz
 * @date 2020/3/29.
 * @Description  检查组 业务接口实现类
 */
@Service
@Transactional
public class CheckGroupServiceImpl implements CheckGroupService {

    @Autowired
    private CheckGroupDao checkGroupDao;

    //检查组  分页查询
    @Override
    public PageResult pageQuery(QueryPageBean queryPageBean) {
      //通过分页助手  pageHelper    实现 设置limit信息
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        //调  dao
      Page<CheckGroup> page = checkGroupDao.selectByCondition(queryPageBean.getQueryString());
       //返回 PageResult 对象

        PageResult pageResult = new PageResult(page.getTotal(), page.getResult());

        return pageResult;
    }
}
